// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   AbExtra.java

package com.oa.archives;

import com.oa.database.*;
import com.oa.util.Format;
import java.io.File;
import java.sql.ResultSet;

// Referenced classes of package com.oa.archives:
//            InnerFileInfor

public class AbExtra
{

    InnerFileInfor innerFileInfor;
    private String str_error;
    private DataConn dataConn;
    private QueryData queryData;
    private Format format;
    private ResultSet rs;
    private String sTable;
    private String sField;
    private String sCond;

    public AbExtra()
    {
        innerFileInfor = null;
        str_error = "";
        dataConn = null;
        queryData = null;
        format = null;
        rs = null;
        sTable = "";
        sField = "";
        sCond = "";
    }

    public AbExtra(DataConn dataConnection)
    {
        innerFileInfor = null;
        str_error = "";
        dataConn = null;
        queryData = null;
        format = null;
        rs = null;
        sTable = "";
        sField = "";
        sCond = "";
        dataConn = dataConnection;
        queryData = new QueryData(dataConn);
    }

    public boolean deleteAbExtra(int iAbExtraId, String realPath)
    {
        if(iAbExtraId <= 0)
            return true;
        String strId = Integer.toString(iAbExtraId);
        File fileAnnex = null;
        sTable = "OA_DAFJ";
        sField = "FJNR";
        sCond = "FJLX=2 AND FJWJ>0 AND FJWJ=" + strId;
        queryData.setMultRecordSet(sTable, sField, sCond);
        ResultSet rs_annex = queryData.getResultSet();
        String annex_path = "";
        String annex_name = "";
        int annex_size = 0;
        try
        {
            while(rs_annex.next()) 
            {
                annex_path = rs_annex.getString("FJNR");
                if(annex_path != null)
                    annex_path = annex_path.trim();
                fileAnnex = new File(realPath + "//" + annex_path);
                if(fileAnnex.exists())
                    fileAnnex.delete();
            }
        }
        catch(Exception e)
        {
            str_error = e.getMessage();
        }
        sTable = "OA_DAFJ";
        sCond = "FJLX=2 AND FJWJ=" + strId;
        DeleteData deleteData = new DeleteData(dataConn);
        deleteData.delete(sTable, sCond);
        sTable = "OA_DACY";
        sCond = "CYWJ=" + strId;
        deleteData.delete(sTable, sCond);
        sTable = "OA_DAWL";
        sCond = "WLID=" + strId;
        deleteData.delete(sTable, sCond);
        return true;
    }

    public static void main(String args[])
    {
        DataConn dataConn = new DataConn();
        AbExtra abExtra = new AbExtra(dataConn);
        abExtra.deleteAbExtra(4, "");
    }
}
